import QQMapW from '../../../utils/qqmap'
Page({
  data: {
    repairList: [],
    empty: false,
    switch: false,
    total: 0,
    parmas: { current: 1, pageSize: 5 },
    latitude: '40.060539',
    longitude: '116.343847'
  },
  onLoad() {
    this.getRepairList()
  },
 
  async getRepairList() {
    wx.showLoading()
    const {
      code,
      data: { rows: repairList, total },
    } = await wx.http.get('/repair', this.data.parmas)
    if (code !== 10000) return wx.utils.toast()
    this.setData({
      total: total,
      repairList: [...this.data.repairList, ...repairList],
      empty: repairList.length === 0
    })
    // console.log(repairList.length)
    wx.hideLoading()
  },
  onReachBottom() {
    console.log(1)
  },
  goDetail(ev) {
    // console.log(ev);
    wx.navigateTo({
      url: '/repair_pkg/pages/detail/index?id=' + ev.mark.id,
    })
  },
  addRepair() {
    wx.navigateTo({
      url: '/repair_pkg/pages/form/index',
    })
  },
  refreshPage() {
    console.log(1)
    this.setData({
      repairList: [],
      empty: false,
      total: 0,
      parmas: {
        current: 1, pageSize: 5
      }
    })
    this.getRepairList()
    this.setData({
      switch: false
    })
  },
  getNextPage() {
    console.log(2)
    if (this.data.repairList.length < this.data.total) {
      this.getRepairList()
    }
  },
})
